<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"  xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<div id="page-content">
    <div class="panel">

        <div class="panel-heading">
            <h3 class="panel-title">楼宇基建信息</h3>
        </div>

        <div class="panel-body">

            <div class="row">
                <div class="col-sm-6 table-toolbar-left">
                    <button type="button" class="btn btn-primary btn-sm" id="btn-buildInfo-add" th:disabled="${!isCreator}">新建楼宇基建信息表</button>
                </div>
                <div class="col-sm-6 table-toolbar-right">
                    <button sec:authorize="hasAuthority('SystemManager')" type="button" class="btn btn-info btn-sm" id="btn-buildInfo-importTemp" onclick="window.open(ctx+'buildInfo/importTemp', '_blank')">下载导入模板</button>
                    <button sec:authorize="hasAuthority('SystemManager')" type="button" class="btn btn-info btn-sm" id="btn-buildInfo-export" onclick="window.open(ctx+'buildInfo/export', '_blank')">导出</button>
                    <button sec:authorize="hasAuthority('SystemManager')" type="button" class="btn btn-info btn-sm" id="btn-buildInfo-import" onclick="__excel_import_view('buildInfo/importData')">导入</button>
                </div>
            </div>

            <div class="jqGrid_wrapper">
                <table id="buildInfo_table"></table>
                <div id="buildInfo_page"></div>
            </div>

        </div>

    </div>
</div>

<script th:inline="javascript">
    $(function(){
        init_grid_buildInfo();
    });

    function init_grid_buildInfo(){
        __init_jqgrid('buildInfo_table', 'buildInfo_page', '/buildInfo/list',
            ["楼域名","总面积(m²)","投资额(万元)","状态","建筑结构","抗震烈度","高度(m)","操作","id"],
            [
                {name: 'name', index: 'name', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'buildMeasure', index: 'buildMeasure', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'investmentAmount', index: 'investmentAmount', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'buildStateDict.name', index: 'buildStateDict.name', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'buildStructureDict.name', index: 'buildStructureDict.name', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'seismicLevelDict.name', index: 'seismicLevelDict.name', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'buildHeight', index: 'buildHeight', width: 100, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'act', index: 'act', width: 150, sortable: false, search: false, formatter: actFormat_buildInfo},
                {name: 'id', index: 'id', width: 100, key: true, hidden: true}
            ]
        );
    }

    function actFormat_buildInfo(cellvalue, options, rowObject){
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-default btn-xs" onclick="fn_buildInfo_read(\'' + id + '\');">查看</button> ';
        return cellvalue;
    }

    //input
    $("#btn-buildInfo-add").on("click", function(){
        __layX_html_read("create", "楼宇基建信息", "/buildInfo/input");
    });

    //read
    function fn_buildInfo_read(id){
        __layX_html_read(id, "楼宇基建信息", "/buildInfo/read?keyId="+id);
    }

</script>

</html>